package com.chenxingnet.controller;


import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.chenxingnet.service.DepartmentService;

@Controller
@RequestMapping("/department")
public class DepartmentController {
	
	@Resource
	private DepartmentService departmentService;
	
	/**
	 * 转至成都城市页面
	 * @return
	 */
	@RequestMapping("/chengCity")
	public String chengCity(HttpServletRequest request,Model model){
		try {
			String rolename = new String(request.getParameter("rolename").getBytes("ISO-8859-1"),"UTF-8");
			if(rolename.equals("会计")){
				model.addAttribute("result", "对不起，您无此操作权限");
				return "account_list";
			}
			Integer deptid = Integer.valueOf(request.getParameter("deptid"));
			if(deptid == 2 && (!rolename.equals("管理员"))){
				model.addAttribute("result", "对不起，您无此操作权限");
				model.addAttribute("deptid", deptid);
				return "aaa_city";
			}else if(deptid == 4 && (!rolename.equals("管理员"))){
				model.addAttribute("result", "对不起，您无此操作权限");
				model.addAttribute("deptid", deptid);
				return "mz_city";
			}
			
		} catch (Exception e) {
		}
		model.addAttribute("deptid", 1);
		return "city";
	}
	/**
	 * 转至绵阳城市页面
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping("/mianCity")
	public String mianCity(HttpServletRequest request,Model model){
		try {
			String rolename = new String(request.getParameter("rolename").getBytes("ISO-8859-1"),"UTF-8");
			if(rolename.equals("会计")){
				model.addAttribute("result", "对不起，您无此操作权限");
				return "account_list";
			}
			Integer deptid = Integer.valueOf(request.getParameter("deptid"));
			if(deptid == 1 && (!rolename.equals("管理员"))){
				model.addAttribute("result", "对不起，您无此操作权限");
				model.addAttribute("deptid", deptid);
				return "city";
			}else if(deptid == 4 && (!rolename.equals("管理员"))){
				model.addAttribute("result", "对不起，您无此操作权限");
				model.addAttribute("deptid", deptid);
				return "mz_city";
			}
		} catch (Exception e) {
			
		}
		model.addAttribute("deptid", 2);
		return "aaa_city";
	}
	/**
	 * 转至绵专城市页面
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping("/mzCity")
	public String mzCity(HttpServletRequest request,Model model){
		try {
			String rolename = new String(request.getParameter("rolename").getBytes("ISO-8859-1"),"UTF-8");
			if(rolename.equals("会计")){
				model.addAttribute("result", "对不起，您无此操作权限");
				return "account_list";
			}
			Integer deptid = Integer.valueOf(request.getParameter("deptid"));
			if(deptid == 1 && (!rolename.equals("管理员"))){
				model.addAttribute("result", "对不起，您无此操作权限");
				model.addAttribute("deptid", deptid);
				return "city";
			}else if(deptid == 2 && (!rolename.equals("管理员"))){
				model.addAttribute("result", "对不起，您无此操作权限");
				model.addAttribute("deptid", deptid);
				return "aaa_city";
			}
		} catch (Exception e) {
			
		}
		model.addAttribute("deptid", 4);
		return "mz_city";
	}
	
	

}
